# 事件
import time
from threading import Thread, Event

# 实例化事件
event = Event()


def light():
    print('红灯')
    time.sleep(3)
    print('绿灯')
    event.set()


def car():
    print('等红灯')
    event.wait()  # 等待set
    print('绿灯启动')


if __name__ == '__main__':
    t = Thread(target=light)
    t.start()

    for i in range(20):
        t = Thread(target=car)
        t.start()
